package com.kaishengit.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.springframework.stereotype.Repository;

import com.kaishengit.pojo.Linkman;
import com.kaishengit.pojo.Linkrecord;

@Repository
@SuppressWarnings("unchecked")
public class LinkrecordDao extends BaseDao<Linkrecord, String> {

	public List<Linkrecord> findAll() {
		String hql = "from Linkrecord order by createtime desc";
		Query query = getSession().createQuery(hql);
		List<Linkrecord> linkrecordList = query.list();
		return linkrecordList;
	}

	public List<Linkrecord> findByLinkMan(Linkman linkman) {
		
		String hql = "from Linkrecord where linkman=:linkman";
		Query query = getSession().createQuery(hql);
		query.setParameter("linkman", linkman);
		List<Linkrecord> linkrecordList = query.list();
		System.out.println(linkrecordList.size());
		return linkrecordList;
	}

	public void delrecord(String id) {
		SQLQuery query = getSession().createSQLQuery(
				"delete from t_linkrecord where id=:id");
		query.setParameter("id", id);
		query.executeUpdate();
		
	}
}
